home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / knowhow4 / blk.cpp < prev    next >
C/C++ Source or Header  |  1994-10-10  |  4KB  |  107 lines

  1. // BLK.CPP
  2.  
  3. #include "blk.h"
  4.  
  5. Block::Block(rect coord, char* fName, char* h, int s,
  6.         int res, BORDERS b_type, BORDERS hdr_b_type,
  7.         int pat, int hdr_pat, int elem_pat)
  8.     : Bl(coord, fName, h, s, res, b_type, hdr_b_type,
  9.         pat, hdr_pat, elem_pat)
  10.     {
  11.     int x = screenXL(coord.corner.X - 2) - w1->get_shadow();
  12.     int y_up = screenYT(coord.origin.Y) + w1->get_shadow();
  13.     int y_pg_up = screenYT(coord.origin.Y + 1) + w1->get_shadow();
  14.     int y_pg_dn = screenYT(coord.corner.Y - 3) - w1->get_shadow();
  15.     int y_dn = screenYT(coord.corner.Y - 2) - w1->get_shadow();
  16.  
  17.     up_element = new Element(rect(x, y_up, x + 2 * pScreenSet->cell_width - 1,
  18.                                   y_up + pScreenSet->cell_height),
  19.                         UP_ELEMENT, BUTTON_BORDER, elem_pat, 1);
  20.     pg_up_element = new Element(rect(x, y_pg_up,
  21.                      x + 2 * pScreenSet->cell_width - 1,
  22.                          y_pg_up + pScreenSet->cell_height),
  23.                          PG_UP_ELEMENT, BUTTON_BORDER, elem_pat, 1);
  24.     pg_dn_element = new Element(rect(x, y_pg_dn,
  25.                      x + 2 * pScreenSet->cell_width - 1,
  26.                          y_pg_dn + pScreenSet->cell_height),
  27.                          PG_DN_ELEMENT, BUTTON_BORDER, elem_pat, 1);
  28.     dn_element = new Element(rect(x, y_dn, x + 2 * pScreenSet->cell_width - 1,
  29.                          y_dn + pScreenSet->cell_height),
  30.                          DN_ELEMENT, BUTTON_BORDER, elem_pat, 1);
  31.  
  32.     left_element = new Element(rect(screenXL(coord.origin.X)
  33.             + w1->get_shadow(),
  34.         screenYT(coord.corner.Y - 1) - w1->get_shadow(),
  35.         screenXR(coord.origin.X) + 2 * pScreenSet->cell_width
  36.             + w1->get_shadow(),
  37.             screenYT(coord.corner.Y) - w1->get_shadow()),
  38.             LEFT_ELEMENT, BUTTON_BORDER, elem_pat, 1);
  39.     right_element = new Element(rect(x, y_dn + pScreenSet->cell_height,
  40.         x + 2 * pScreenSet->cell_width - 1,
  41.         y_dn + 2 * pScreenSet->cell_height),
  42.             RIGHT_ELEMENT, BUTTON_BORDER, elem_pat, 1);
  43.  
  44.     add(up_element);
  45.     add(dn_element);
  46.     add(pg_up_element);
  47.     add(pg_dn_element);
  48.     add(left_element);
  49.     add(right_element);
  50.     moveTo(1);
  51.     }
  52. //////////////////
  53. void Block::rearrange()
  54.     {
  55.     Bl::rearrange();
  56.     rect coord = textRect(w1->bound());
  57.     w1->repose(coord);
  58.  
  59.     int x = screenXL(coord.corner.X - 2) - w1->get_shadow();
  60.     int y_up = screenYT(coord.origin.Y) + w1->get_shadow();
  61.     int y_pg_up = screenYT(coord.origin.Y + 1) + w1->get_shadow();
  62.     int y_pg_dn = screenYT(coord.corner.Y - 3) - w1->get_shadow();
  63.     int y_dn = screenYT(coord.corner.Y - 2) - w1->get_shadow();
  64.  
  65.     up_element->repose(rect(x, y_up, x + 2 * pScreenSet->cell_width - 1,
  66.                                   y_up + pScreenSet->cell_height));
  67.     pg_up_element->repose(rect(x, y_pg_up,
  68.                      x + 2 * pScreenSet->cell_width - 1,
  69.                          y_pg_up + pScreenSet->cell_height));
  70.     pg_dn_element->repose(rect(x, y_pg_dn,
  71.                      x + 2 * pScreenSet->cell_width - 1,
  72.                          y_pg_dn + pScreenSet->cell_height));
  73.     dn_element->repose(rect(x, y_dn, x + 2 * pScreenSet->cell_width - 1,
  74.                          y_dn + pScreenSet->cell_height));
  75.  
  76.     left_element->repose(rect(screenXL(coord.origin.X)
  77.             + w1->get_shadow(),
  78.         screenYT(coord.corner.Y - 1) - w1->get_shadow(),
  79.         screenXR(coord.origin.X) + 2 * pScreenSet->cell_width
  80.             + w1->get_shadow(),
  81.             screenYB(coord.corner.Y) - w1->get_shadow()));
  82.         right_element->repose(rect(x, y_dn + pScreenSet->cell_height,
  83.         x + 2 * pScreenSet->cell_width - 1,
  84.         y_dn + 2 * pScreenSet->cell_height));
  85.  
  86.     }
  87. ////////////////////////
  88. /*
  89. void main()
  90.     {
  91.     if(!init_KNOW_HOW())
  92.         return;
  93.     setfillstyle(SOLID_FILL, pColorSet->colors.BAK_COLOR);
  94.     bar(0, 0, getmaxx(), getmaxy());
  95.  
  96.     Block b(rect(10, 10, 60, 20), "window.pcy", "Block", 6,
  97.         MOVE | RESIZE | SCROLL_VERT,
  98.         SHOW_BORDER, SHOW_BORDER,
  99.         16, 17, 16);
  100.  
  101.     b.show();
  102.     b.exe();
  103.  
  104.     close_KNOW_HOW();
  105.     closegraph();
  106.     }
  107. */